"""
@Project ：Python_Learning 
@File    ：35.搜索插入位置.py
@IDE     ：PyCharm 
@Author  ：zhupp
@Date    ：2024/10/16 13:52 
"""

class Solution:
    def searchInsert(self, nums: list[int], target: int) -> int:
        left, right = 0, len(nums) - 1
        while left <= right:
            mid = (left + right) // 2
            if target == nums[mid]:
                return mid
            elif target < nums[mid]:
                right = mid - 1
            elif target > nums[mid]:
                left = mid + 1

s = Solution()
print(s.searchInsert([1, 3, 5, 6], 2))
